//
//  VideoViewController.swift
//  koolcar
//
//  Created by kuaimaxiansheng on 2023/10/21.
//

import UIKit
import AVKit

class VideoViewController: BaseViewController {
    var lPlayer: CLPlayer!
    var bgView: UIView!
    var titleStr = ""
    var videoUrl = ""
    override func viewDidLoad() {
        super.viewDidLoad()
        self.navBar.title = self.titleStr
        self.bgView = UIView(frame: CGRect(x: 0, y: NavBarHight, width: kScreenWidth , height: kScreenHeight - NavBarHight))
        self.bgView.backgroundColor = .black
        self.view.addSubview(self.bgView)
        
        
        if self.lPlayer == nil {
            self.lPlayer = CLPlayer(frame: CGRect(x: 0, y: 0, width: kScreenWidth, height: self.bgView.frame.size.height - TabbarHeight))
            self.bgView.addSubview(self.lPlayer)
        }
        self.lPlayer.url = URL(string: self.videoUrl)
        self.lPlayer.play()

        
        //是否隐藏删除按钮
        self.lPlayer.showFullScreenBlock = { (show: Bool) in
            if show == false{
                
            }else{
               
            }
        }
    }
   
    override func backAction() {
        super.backAction()
        self.lPlayer?.pause()
        self.lPlayer?.removeFromSuperview()
        self.lPlayer = nil
    }

}
